package com.lebang.service.buss;

import com.lebang.entity.LbbAppStore;
import com.lebang.entity.sys.LbbModule;
import com.lebang.example.LbbModuleExample;
import com.lebang.mapper.LbbAppStoreMapper;
import com.lebang.mapper.LbbModuleMapper;
import com.lebangweb.common.TextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * module
 *
 * @author weizx
 */
@Service
public class ModuleService {

    @Autowired
    private LbbAppStoreMapper lbbAppStoreMapper;
    @Autowired
    private LbbModuleMapper lbbModuleMapper;

    /**
     * 替换参数
     *
     * @param code
     * @param params
     * @return
     */
    public String transParams(String code, String params) {
        if (!TextUtil.isEmpty(params) && params.contains("{cid}")) {
            LbbAppStore appstore = lbbAppStoreMapper.selectByCode(code);
            if (null == appstore) {
                return params;
            }
            return params.replace("{cid}", appstore.getCid());
        }
        return params;
    }



    public List<LbbModule> getListByExample(LbbModuleExample example) {
        return lbbModuleMapper.selectByExample(example);
    }
}
